package com.lifang.framework.aop.aspectj;

import com.lifang.framework.aop.framework.ReflectiveMethodInvocation;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.aspectj.lang.JoinPoint;

import java.lang.reflect.Method;

public class AspectJAroundAdvice extends AbstractAspectJAdvice implements MethodInterceptor {

    public AspectJAroundAdvice(Method aspectJAdviceMethod, AspectJExpressionPointcut pointcut) {
        super(aspectJAdviceMethod, pointcut);
    }

    @Override
    public int getOrder() {
        return 1;
    }

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        JoinPoint joinPoint = currentJoinPoint((ReflectiveMethodInvocation) invocation);
        return invokeAdviceMethod(joinPoint);
    }
}
